# Maintainer: Christian Hesse <mail@eworm.de>
# Contributor: Rustam Tsurik <rustam.tsurik@gmail.com>
# Contributor: Nico Suarez <nicodoggie@gmail.com>

pkgname=galera
pkgver=26.4.14
_mariadb_ver=10.9.5
pkgrel=1
pkgdesc='write set replication (WSREP) provider for MariaDB cluster'
arch=('x86_64')
license=('GPL2' 'custom:OpenSSL Linking Exception')
depends=('mariadb' 'openssl')
makedepends=('boost' 'check' 'cmake')
optdepends=('rsync: State Snapshot Transfers with rsync'
            'socat: State Snapshot Transfers with mariabackup')
url='https://galeracluster.com/'
options=('!libtool')
validpgpkeys=('177F4010FE56CA3336300305F1656F24C74CD1D8') # MariaDB Signing Key <signing-key@mariadb.org>
source=("https://rsync.osuosl.org/pub/mariadb/mariadb-${_mariadb_ver}/galera-${pkgver}/src/galera-${pkgver}.tar.gz"{,.asc})
sha256sums=('9d3b569f84c7cd98ee5edef05f059482cb01c8e2e6d5b6d0cba7873691118a4b'
            'SKIP')

prepare() {
  cd "${pkgname}-${pkgver}"

  sed -i '/^GALERA_VER/s/API + //' wsrep/tests/SConscript
}

build(){
  cd "${pkgname}-${pkgver}"

  cmake .
  make
}

package(){
  cd "${pkgname}-${pkgver}"

  install -D -m0755 libgalera_smm.so "${pkgdir}"/usr/lib/galera/libgalera_smm.so
  ln -s galera/libgalera_smm.so "${pkgdir}"/usr/lib/libgalera_smm.so

  install -D -m0755 garb/garbd "${pkgdir}"/usr/bin/garbd

  install -D -m0644 scripts/packages/README "${pkgdir}"/usr/share/doc/galera/README
  install -D -m0644 scripts/packages/README-MySQL "${pkgdir}"/usr/share/doc/galera/README-MySQL
  install -D -m0644 scripts/mysql/README "${pkgdir}"/usr/share/doc/galera/mysql/README
  install -D -m0644 COPYING "${pkgdir}"/usr/share/doc/galera/COPYING
}
